foreach (GridViewRow row in grid.Rows) { int id = Convert.ToInt32(grid.DataKeys[row.RowIndex].Value.ToString()); }